﻿<html>
<head>
    <meta name="viewport" content="width=device-width" />

    <environment include="Development">
        <link href="~/lib/twitter-bootstrap/css/bootstrap.css" rel="stylesheet" />
        <link href="~/lib/fontawesome/css/font-awesome.css" rel="stylesheet" />
    </environment>

    <environment exclude="Development">
        <link rel="stylesheet"
              href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
              integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
              crossorigin="anonymous"
              asp-fallback-href="~/lib/twitter-bootstrap/css/bootstrap.min.css"
              asp-fallback-test-class="sr-only"
              asp-fallback-test-property="position"
              asp-fallback-test-value="absolute"
              asp-suppress-fallback-integrity="true" />
        <link href="~/lib/fontawesome/css/font-awesome.min.css" rel="stylesheet" />
    </environment>
 
    <link href="~/css/site.css" rel="stylesheet" asp-append-version="true" />
    <title>@ViewBag.Title</title>
</head>
<body>
    <div class="container">
        <nav class="navbar navbar-expand-sm bg-dark navbar-dark">
            <a class="navbar-brand" asp-controller="home" asp-action="index">
                <img src="~/images/student.png" width="30" height="30" />
            </a>
            <button class="navbar-toggler"
                    type="button"
                    data-toggle="collapse"
                    data-target="#collapsibleNavbar">
                <span class="navbar-toggler-icon"></span>
            </button>
            @using Microsoft.AspNetCore.Identity
            @inject SignInManager<ApplicationUser> _signInManager
            <div class="collapse navbar-collapse" id="collapsibleNavbar">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" asp-controller="home" asp-action="index">学生列表</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" asp-controller="Course" asp-action="index">课程管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" asp-controller="Teacher" asp-action="index">教师管理</a>
                    </li> <li class="nav-item">
                        <a class="nav-link" asp-controller="Departments" asp-action="index">部门管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" asp-controller="home" asp-action="About">关于我们</a>
                    </li>

                    @if (_signInManager.IsSignedIn(User))
                    {

                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle"
                               href="#"
                               id="navbarDropdownMenuLink"
                               data-toggle="dropdown"
                               aria-haspopup="true"
                               aria-expanded="false">
                                管理
                            </a>

                            <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">

                                @if (User.IsInRole("Admin"))
                                {
                                    <a class="dropdown-item" asp-controller="Admin" asp-action="ListUsers">用户列表</a>
                                    <a class="dropdown-item" asp-controller="Admin" asp-action="ListRoles">角色列表</a>
                                }
                                <a class="dropdown-item" asp-controller="Account"
                                   asp-action="ChangePassword">
                                    密码管理
                                </a>
                            </div>
                        </li>
                    }
                </ul>
                <ul class="navbar-nav ml-auto">
                    @*如果用户已登录，则显示注销链接*@
                    @if (_signInManager.IsSignedIn(User))
                    {
                        <li class="nav-item">
                            <form method="post" asp-controller="account" asp-action="logout">
                                <button type="submit" style="width:auto"
                                        class="nav-link btn btn-link py-0">
                                    注销 @User.Identity.Name
                                </button>
                            </form>
                        </li>
                    }
                    else
                    {
                        <li class="nav-item">
                            <a class="nav-link" asp-controller="account" asp-action="register">
                                注册
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" asp-controller="account" asp-action="login">
                                登录
                            </a>
                        </li>
                    }
                </ul>
            </div>
        </nav>
        @RenderBody()
    </div>

    <environment include="Development">
        <script src="~/lib/jquery/dist/jquery.js"></script>
        <script src="~/lib/twitter-bootstrap/js/bootstrap.js"></script>
        <script src="~/lib/jquery-validate/jquery.validate.js"></script>
        <script src="~/lib/jquery-validate-unobtrusive/jquery.validate.unobtrusive.js"></script>
     </environment>
    <environment exclude="Development">
        <script src="~/lib/jquery/dist/jquery.min.js"></script>
        <script src="~/lib/twitter-bootstrap/js/bootstrap.js"></script>
        <script src="~/lib/jquery-validate/jquery.validate.min.js"></script>
        <script src="~/lib/jquery-validate-unobtrusive/jquery.validate.unobtrusive.min.js"></script>

     </environment>

    @if (IsSectionDefined("Scripts"))
    {@RenderSection("Scripts", required:
false)}
</body>
</html>